home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / efun / clear_bit < prev    next >
Text File  |  2001-04-06  |  1KB  |  38 lines

  1. SYNOPSIS
  2.         string clear_bit(string str, int n)
  3.  
  4. DESCRIPTION
  5.         Return the new string where bit n is cleared in string str.
  6.         Note that the old string str is not modified.
  7.         
  8.         Each character contains 6 bits. So you can store a value
  9.         between 0 and 63 ( 2^6=64) in one character. Starting
  10.         character is the blank character " " which has the value 0.
  11.         The first charcter in the string is the one with the lowest
  12.         bits (0-5).
  13.  
  14. EXAMPLES
  15.         string s;
  16.         s=clear_bit("_",5);
  17.         
  18.         Because "_" is the highest possible value (63), the variable s
  19.         will now contain the charcter "?" wich is equal to 31
  20.         (63-2^5=31).
  21.         
  22.         string s;
  23.         s=clear_bit("?<",3);
  24.         s=clear_bit(s,8);
  25.         
  26.         s will now contain the string "78". "?" equals 31 and "<"
  27.         equals 28. Now "?<" is equal to 31+28<<6=31+1792=1823 which is
  28.         in binary notation (highest bit on the right side)
  29.         11111000111. Now clearing the bit 3 and bit 8 (bit numbering
  30.         starts with zero) will result in 11101000011. The first 6 bits
  31.         are in decimal notation 23 and the next 6 are equal to 24. Now
  32.         the 23 is the character "7" and 24 is the "8". So the string s
  33.         contains "78".
  34.  
  35. SEE ALSO
  36.         set_bit(E), next_bit(E), last_bit(E), test_bit(E), count_bits(E),
  37.         and_bits(E), or_bits(E), xor_bits(E), invert_bits(E)
  38.